<!--
	Desc: 	生成方案管理的编辑界面
	Author: caochaofeng
	Date: 	2019-04-10 17:20:53
-->

<template>
  <el-dialog
    :title="!dataForm.id ? '新增生成方案' : '修改生成方案'"
    :close-on-click-modal="false"
    :append-to-body="true"
    :visible.sync="visible"
    width="60%"
    top="8vh">
    <el-form ref="dataForm" :model="dataForm" label-width="120px" @keyup.enter.native="dataFormSubmit()">
      <el-form-item
        :rules="[{required: true,message: '请输入方案名称'}]"
        inline-message="生成结构：(包名)/(模块名)/(分层(dao,entity,service,web))/(子模块名)/(java类)"
        label="方案名称"
        prop="name">
        <el-input v-model="dataForm.name"/>
      </el-form-item>
      <el-form-item
        :rules="[{required: true,message: '请选择模块分类'}]"
        label="模块分类"
        prop="category">
        <CrudSelect :dic="categoryList" v-model="dataForm.category"/>
      </el-form-item>
      <el-form-item
        :rules="[{required: true,message: '请输入生成包路径'}]"
        label="生成包路径"
        prop="packageName">
        <el-input v-model="dataForm.packageName"/>
      </el-form-item>
      <el-form-item
        :rules="[{required: true,message: '请输入生成模块名'}]"
        label="生成模块名"
        prop="moduleName">
        <el-input v-model="dataForm.moduleName"/>
      </el-form-item>
      <el-form-item label="生成子模块名" prop="subMenuName">
        <el-input v-model="dataForm.subMenuName"/>
      </el-form-item>
      <el-form-item
        :rules="[{required: true,message: '请输入生成功能描述'}]"
        label="生成功能描述"
        prop="functionName">
        <el-input v-model="dataForm.functionName"/>
      </el-form-item>
      <el-form-item
        :rules="[{required: true,message: '请输入生成功能名'}]"
        label="生成功能名"
        prop="functionNameSimple">
        <el-input v-model="dataForm.functionNameSimple"/>
      </el-form-item>
      <el-form-item
        :rules="[{required: true,message: '请输入生成功能作者'}]"
        label="生成功能作者"
        prop="functionAuthor">
        <el-input v-model="dataForm.functionAuthor"/>
      </el-form-item>
      <el-form-item
        :rules="[{required: true,message: '请选择业务表名'}]"
        label="业务表名"
        prop="tableId">
        <CrudSelect :dic="tableList" v-model="dataForm.tableId"/>
      </el-form-item>
      <el-form-item label="生成选项">
        <el-switch v-model="dataForm.genCode" active-text="是否生成代码"/>
        <el-switch v-model="dataForm.replaceFile" active-text="是否替换现有文件"/>
      </el-form-item>
      <el-form-item label="备注" prop="description">
        <el-input v-model="dataForm.description" placeholder="" type="textarea"/>
      </el-form-item>

    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import mixinFormViewModule from '@/mixins/form-view-module'
import * as API from '@/api/gen/scheme'
import CrudSelect from '@/components/avue/crud-select'
import CrudRadio from '@/components/avue/crud-radio'
import Ace from '@/components/ace/index'
export default {
  components: { CrudSelect, CrudRadio, Ace },
  mixins: [mixinFormViewModule],
  data() {
    return {
      visible: false,
      viewTypeList: [
        { 'value': '0', 'label': '普通视图' },
        { 'value': '1', 'label': '弹窗视图' }
      ],
      categoryList: [
        { 'value': 'curd', 'label': '增删改查（单表）' },
        { 'value': 'curd_back', 'label': '增删改查（单表）- 后端' },
        { 'value': 'curd_front', 'label': '增删改查（单表）- 前端' },
        { 'value': 'service', 'label': '仅持久层（service/entity）' },
        { 'value': 'entity', 'label': '数据层（entity）' },
        { 'value': 'treeTable', 'label': '树结构表（一体）' },
        { 'value': 'treeTable_back', 'label': '树结构表（一体）- 前端' },
        { 'value': 'treeTable_front', 'label': '树结构表（一体）- 前端' }
      ],
      tableList: [],
      dataForm: {
        id: 0,
        name: undefined,
        tableName: undefined,
        packageName: undefined,
        moduleName: undefined,
        subMenuName: undefined,
        functionName: undefined,
        functionNameSimple: undefined,
        functionAuthor: undefined,
        tableId: undefined,
        genCode: undefined,
        replaceFile: undefined,
        syncMenu: undefined,
        status: undefined,
        description: undefined
      },
      mixinViewModuleOptions: {
        getInfoAPI: API.info, // 数据详情列表接口，API地址

        addAPI: API.add, // 新增接口，API地址
        updateAPI: API.update // 修改接口，API地址
      }
    }
  },
  methods: {

  }
}
</script>
